import React from 'react';
import { QRCode as AntdQRCode } from 'antd';
import type { QRCodeProps as AntdQRCodeProps } from 'antd';
import { createStyles } from 'antd-style';

export interface QRCodeProps extends AntdQRCodeProps {
  /**
   * @description 自定义样式类名
   */
  customClassName?: string;
}

const useStyles = createStyles(({ token, css }) => ({
  qrcode: css`
    border-radius: ${token.borderRadius}px;
  `,
}));

const QRCode: React.FC<QRCodeProps> = ({ customClassName, className, ...restProps }) => {
  const { styles, cx } = useStyles();
  
  const qrcodeClassName = cx(
    className,
    customClassName,
    styles.qrcode
  );

  return <AntdQRCode className={qrcodeClassName} {...restProps} />;
};

export { QRCode };
export default QRCode;

